{extend name="common"}

{block name="content"}
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>修改权限</legend>
</fieldset>
<form class="layui-form" action="" method="">
    <div class="layui-form-item" style="display: none">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" required lay-verify="username" autocomplete="off" placeholder="请输入用户名"
                   class="layui-input" style="width: 70%" value="{$group.username}">
        </div>
    </div>

    <div class="layui-form-item" style="width: 80%">
        <label class="layui-form-label">权限</label>
        <div class="layui-input-block">
            <select name="perm" id="perm">
                <option value="">请选择权限</option>
                <option value="3" {switch name="$group.group" } {case value="管理员"}selected{/case}{default /}{/switch}>管理员</option>
                <option value="0" {switch name="$group.group" } {case value="设计组"}selected{/case}{default /}{/switch}>设计组</option>
                <option value="2" {switch name="$group.group" } {case value="工程组"}selected{/case}{default /}{/switch}>工程组</option>
                <option value="1" {switch name="$group.group" } {case value="商务组"}selected{/case}{default /}{/switch}>商务组</option>
                <option value="4" {switch name="$group.group" } {case value="财务组"}selected{/case}{default /}{/switch}>财务组</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="adduser">修改</button>
        </div>
    </div>
</form>

{/block}

{block name="script"}
<script>
    layui.use(['form'], function () {
        var form = layui.form;
        var $ = layui.jquery;

        form.on('submit(adduser)', function (data) {
            var load = layer.load();
            $.ajax({
                url: "{:url('User/upperm')}",
                type: "POST",
                data: data.field,
                dataType: 'json',
                success: function (res) {
                    if (1 == res.code) {
                        layer.msg(res.msg, {icon: 1}, function () {
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    layer.close(load);
                }
            });
            return false;
        });
    });
</script>
{/block}